'use strict';

const Service = require('egg').Service;

class ClientService extends Service {
  async login(username, password) {
  
    const { ctx, app } = this;
    const user = await app.mysql.get('shopkeeper', { username, password });
    return { code: 200, msg: '', status: 'success', data: user };
  }

  async modifyOrderStatus(orderId, status) {
    const { ctx, app } = this;
    const options = {
      where: {
        order_id:orderId
      }
    };
    const result = await app.mysql.update('orders',{status}, options);
    if (result.affectedRows === 1) {
      return { code: 200, msg: '', status: 'success', data: { } }
    } else {
      return { code: 200, msg: '修改地址失败 请刷新页面重试!', status: 'failure' }
    }
  }
}
module.exports = ClientService;